package com.example.chirdrenserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.chirdrenserver.Pojo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("SELECT * FROM user WHERE nickname LIKE CONCAT('%', #{nickname}, '%')")
    List<User> findByNickname(String nickname);

    @Select("SELECT * FROM user WHERE email = #{email}")
    User findByEmail(String email);

    // 修正：返回 Integer 类型
    @Select("SELECT role_id FROM user_role WHERE user_id = #{userId}")
    List<Integer> findRoleIdsByUserId(Long userId);
}